home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / c / cclib / include / stdio.h < prev    next >
C/C++ Source or Header  |  1995-11-16  |  4KB  |  197 lines

  1. #ifndef STDIO_H
  2. #define STDIO_H 1
  3.  
  4. #ifndef NULL
  5. #define NULL 0L
  6. #endif
  7. #define EOF -1
  8.  
  9. /* size of the buffer for buffered files... */
  10. #define BUFSIZ 1024L
  11.  
  12. #define _BUSY (1<<0)
  13. #define _ALLBUF (1<<1)
  14. #define _DIRTY (1<<2)
  15. #define _EOF (1<<3)
  16. #define _IOERR (1<<4)
  17. #define _TEMP (1<<5)
  18.  
  19. /* Flags for setvbuf */
  20. #define _IOFBF 1L
  21. #define _IOLBF 2L
  22. #define _IONBF 3L
  23. /* errors from setvbuf */
  24. #define HASBUF 1L
  25. #define NOBUFMEM 2L
  26.  
  27. /* seek positions */
  28. #define SEEK_SET 0L
  29. #define SEEK_CUR 1L
  30. #define SEEK_END 2L
  31.  
  32. typedef struct
  33. {
  34. long _unit;        /* token returned by open -> FileDesc */
  35. char *_bp;        /* position in character buffer */
  36. char *_bend;        /* end of buffer */
  37. char *_buff;        /* start */
  38. char _flags;        /* open mode  */
  39. char _bytbuf;        /* single character buffer (non-bufered files) */
  40. short _buflen;        /* # characters in buffer */
  41. char *_tmpname;     /* temporary file name */
  42. } FILE;
  43.  
  44. extern FILE *stdin, *stdout, *stderr;
  45.  
  46. /* use function calls instead, if NOMACROS is defined */
  47. #ifndef NOMACROS
  48.  
  49. #define getchar() agetc(stdin)
  50. #define putchar(c) aputc(c, stdout)
  51.  
  52. #else
  53.  
  54. #ifdef ANSIC
  55. long getchar(void);
  56. long putchar(long c);
  57. #else
  58. long getchar();
  59. long putchar();
  60. #endif
  61.  
  62. #endif
  63.  
  64. /* macros... */
  65. #define feof(STREAM) ( ((FILE *)(STREAM))->_flags&_EOF )
  66. #define ferror(STREAM) ( ((FILE *)(STREAM))->_flags&_IOERR )
  67. #define clearerr(STREAM) ( ((FILE *)(STREAM))->_flags &= ~(_IOERR|_EOF) )
  68. #define fileno(STREAM) ( ((FILE *)(STREAM))->_unit )
  69. #define rewind(STREAM) (fseek((FILE *)(STREAM), 0L, SEEK_SET))
  70. #define remove(NAME) ( unlink((char *)(NAME)) )
  71. #define setbuf(STREAM,BUFFER)\
  72.  (setvbuf(STREAM,BUFFER,BUFFER ? _IOFBF : _IONBF,BUFSIZ))
  73. #define fgetc(STREAM) ((int)agetc(STREAM))
  74. #define fputc(CH,STREAM) ((int)aputc((int)(CH),STREAM))
  75.  
  76. /* The name of the C DLL is here. */
  77. #define CCLIBNAME "CClib.library"
  78.  
  79. /* The only practical limit to the number of
  80.  * opened files is the amount of memory in the
  81.  * computer.
  82.  */
  83. #define FOPEN_MAX 2147483647L
  84.  
  85. /* the length of a temporary file name */
  86. #define L_tmpnam    30
  87. #define TMP_MAX FOPEN_MAX
  88.  
  89. /* The theoretical maximum of the number of
  90.  * characters in a file is 107 but the current
  91.  * limit is set to 30. This doesn't include
  92.  * the path name.
  93.  */
  94. #define FILENAME_MAX 107
  95.  
  96. #ifndef __SIZE_T
  97. #define __SIZE_T 1
  98. typedef unsigned long size_t;
  99. #endif
  100.  
  101. #ifndef __FPOS_T
  102. #define __FPOS_T 1
  103. typedef long fpos_t;
  104. #endif
  105.  
  106. #ifndef __SYS_ERRLIST
  107. #define __SYS_ERRLIST 1
  108. /* these correspond to the error codes returned in errno */
  109. extern char *sys_errlist[];
  110. #define sys_nerr 9
  111. #endif
  112.  
  113. #ifdef ANSIC
  114.  
  115. #ifndef STDARG_H
  116. #include "stdarg.h"
  117. #endif
  118.  
  119. FILE *fopen(char *,char *);
  120. FILE *freopen(char *, char *, FILE *);
  121. long fflush(FILE *);
  122. long fclose(FILE *);
  123. long unlink(char *);
  124. long rename(char *,char *);
  125. FILE *tmpfile(void);
  126. char *tmpnam(char *);
  127. long setvbuf(FILE *,char *,long,size_t);
  128. long fprintf(FILE *, char *, ...);
  129. long printf(char *, ...);
  130. long sprintf(char *, char *,...);
  131. long vprintf(char *,va_list);
  132. long vfprintf(FILE *,char *,va_list);
  133. long vsprintf(char *,char *,va_list);
  134. long fscanf(FILE *, char *, ...);
  135. long scanf(char *, ...);
  136. long sscanf(char *, char *, ...);
  137. char *fgets(char *, long, FILE *);
  138. long fputs(char *, FILE *);
  139. long getc(FILE *);
  140. char *gets(char *);
  141. long putc(long ,FILE *);
  142. long aputc(long, FILE *);
  143. long agetc(FILE *);
  144. long puts(char *);
  145. long ungetc(long,FILE *);
  146. size_t fread(void *,size_t,size_t,FILE *);
  147. size_t fwrite(void *,size_t,size_t,FILE *);
  148. long fseek(FILE *,long,long);
  149. long ftell(FILE *);
  150. long fgetpos(FILE *,fpos_t *);
  151. long fsetpos(FILE *,fpos_t *);
  152. long perror(char *);
  153.  
  154.  
  155. #else
  156.  
  157. FILE *fopen();
  158. FILE *freopen();
  159. long fflush();
  160. long fclose();
  161. long unlink();
  162. long rename();
  163. FILE *tmpfile();
  164. char *tmpnam();
  165. long setvbuf();
  166. long fprintf();
  167. long printf();
  168. long sprintf();
  169. long vprintf();
  170. long vfprintf();
  171. long vsprintf();
  172. long fscanf();
  173. long scanf();
  174. long sscanf();
  175. char *fgets();
  176. long fputs();
  177. long getc();
  178. char *gets();
  179. long putc();
  180. long aputc();
  181. long agetc();
  182. long puts();
  183. long ungetc();
  184. size_t fread();
  185. size_t fwrite();
  186. long fseek();
  187. long ftell();
  188. long fgetpos();
  189. long fsetpos();
  190. long perror();
  191.  
  192.  
  193. #endif
  194.  
  195. #endif
  196.  
  197.